# coding: utf-8
import numpy as np
import pandas as pd



a = [1,2,3,4,5]
myvar = pd.Series(a)
print(myvar)

a = ['google', 'baidu', 'alibaba', 'tencent', 'xiaomi']
myvar = pd.Series(a, index = ['a','b','c','d','e'])
print(myvar.iloc[0])



data = [['google',10],['baidu',20],['alibaba',30]]

df = pd.DataFrame(data, columns = ['Company','Price'])

print(df)

print(df['Company'])



stock_df = pd.read_csv('../data/sh_600519_20230101_20230901_dirty.csv')

print(stock_df[['open','close']])
print(stock_df.loc[10])
print(stock_df.iloc[10])

print(stock_df.query('open > 1900'))



print(stock_df.dropna(axis=0,how='any', inplace=False))
print(stock_df.ffill(axis=0,inplace=False))
print(stock_df.drop_duplicates(subset=['open','close']))



print(list(stock_df.groupby(by='code')))

print(stock_df[['open','close']].agg(['mean','max','min']))

stock_df.ffill(axis=0,inplace=True)
stock_df.replace(0,method='ffill',inplace=True)
